<template>
<el-container style=" border: 1px solid #eee;">
  <el-aside width="200px" style="background-color: rgb(238, 241, 246); height:1000px;">
    <el-menu :default-openeds="[]" router=true>
      <el-menu-item index="/admin">
        <i class="el-icon-s-order"></i>
        <span slot="title">今日总览</span>
      </el-menu-item>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>数据统计</template>
        <el-menu-item index="/admin/Unhealth" >身体异常人员</el-menu-item>
        <el-menu-item index="/admin/DangerTrip" >风险行程统计</el-menu-item>
      </el-submenu>
      <el-menu-item index="/admin/usermanage">
        <i class="el-icon-s-order"></i>
        <span slot="title">账号管理</span>
      </el-menu-item>
    </el-menu>
  </el-aside>

  <el-container>
    <el-header style="text-align: right; font-size: 12px; background-color: #EBEEF5">
      <el-dropdown @command="handleCommand">
        <i class="el-icon-more" style="margin-right: 40px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="logout">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    <el-main>
      <router-view name="maincontent"/>
    </el-main>
  </el-container>
</el-container>
</template>
<style>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }

  .el-aside {
    color: #333;
  }
</style>

<script>
import axios from 'axios'
export default {
  name: 'Mainpage',
  data () {
    return {
      testv: 'gogo'
    }
  },
  methods: {
    handleCommand (command) {
      if (command === 'logout') {
        axios({
          withCredentials: true,
          maxRedirects: 0,
          method: 'post',
          url: '/admin/logout',
          timeout: 4000
        }, ErrorEvent => {
          this.$message('登出失败')
        }).then((res) => {
        }, ErrorEvent => {
          location.href = 'http://localhost:8080/admin/login_backend'
        })
      }
    }
  }
}
</script>
